/*
 * SysConfig Configuration Steps:
 *   GPIO:
 *     1. Add a GPIO module.
 *     2. Name the group as "GPIO_SOFT_OLED".
 *     3. Name the pins as "PIN_SCL" and "PIN_SDA".
 *     4. Set the pins according to your needs.
 */

#ifndef __OLED_SOFTWARE_I2C_H
#define __OLED_SOFTWARE_I2C_H

#include "ti_msp_dl_config.h"
#include <stdint.h>
#include <stdbool.h>

// OLED命令和数据标志
#define OLED_CMD  0	// 写命令
#define OLED_DATA 1	// 写数据

//----------------------------------------------------------------------------------
//OLED SSD1306 I2C 时钟SCL
#define		OLED_SCL_Set()			    (DL_GPIO_setPins(GPIO_SOFT_OLED_PORT, GPIO_SOFT_OLED_PIN_SCL_PIN))
#define		OLED_SCL_Clr()				(DL_GPIO_clearPins(GPIO_SOFT_OLED_PORT, GPIO_SOFT_OLED_PIN_SCL_PIN))

//----------------------------------------------------------------------------------
//OLED SSD1306 I2C 数据SDA
#define		OLED_SDA_Set()				(DL_GPIO_setPins(GPIO_SOFT_OLED_PORT, GPIO_SOFT_OLED_PIN_SDA_PIN))
#define		OLED_SDA_Clr()			    (DL_GPIO_clearPins(GPIO_SOFT_OLED_PORT, GPIO_SOFT_OLED_PIN_SDA_PIN))

// 添加SDA方向控制
#define     OLED_SDA_IN()               (DL_GPIO_disableOutput(GPIO_SOFT_OLED_PORT, GPIO_SOFT_OLED_PIN_SDA_PIN))
#define     OLED_SDA_OUT()              (DL_GPIO_enableOutput(GPIO_SOFT_OLED_PORT, GPIO_SOFT_OLED_PIN_SDA_PIN))
#define     OLED_SDA_Read()             (DL_GPIO_readPins(GPIO_SOFT_OLED_PORT, GPIO_SOFT_OLED_PIN_SDA_PIN))
				   

//OLED控制用函数
void delay_ms(uint32_t ms);
void OLED_ColorTurn(uint8_t i);
void OLED_DisplayTurn(uint8_t i);
void OLED_Display_On(void);
void OLED_Display_Off(void);
void OLED_Clear(void);
void OLED_ShowChar(uint8_t x, uint8_t y, uint8_t chr, uint8_t sizey);
void OLED_ShowNum(uint8_t x, uint8_t y, uint32_t num, uint8_t len, uint8_t sizey);
void OLED_ShowString(uint8_t x, uint8_t y, uint8_t *chr, uint8_t sizey);
void OLED_ShowChinese(uint8_t x, uint8_t y, uint8_t no, uint8_t sizey);
void OLED_DrawBMP(uint8_t x, uint8_t y, uint8_t sizex, uint8_t sizey, uint8_t BMP[]);
void OLED_Init(void);
void OLED_Refresh(void);

// 使用oledfont.h中的字体数组定义
// 注意：oledfont.h中使用unsigned char，这里直接引用外部定义
extern const unsigned char asc2_0806[][6];
extern const unsigned char asc2_1608[][16];
extern const unsigned char Hzk[][32];



#endif /* __OLED_SOFTWARE_I2C_H */
